from typing import *
from math import inf


class Solution:

    def maximumTripletValue(self, nums: List[int]) -> int:
        mx, diff = nums[0], nums[0] - nums[1]
        ans = 0
        for i in range(2, len(nums)):
            diff = max(diff, mx - nums[i - 1])
            ans = max(ans, diff * nums[i])
            mx = max(mx, nums[i - 1])

        return ans